package com.hongyuan.sellfitness.ui.home.view_mode;

import android.app.Application;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.CustomViewModel;
import com.hongyuan.sellfitness.data.MyRepository;
import com.hongyuan.sellfitness.ui.home.activity.BuyCardActivity;
import com.hongyuan.sellfitness.ui.home.beans.CardDetailsBean;

public class CardDetailsViewModel extends CustomViewModel<MyRepository> {

    public ObservableField<CardDetailsBean> entity = new ObservableField<>();

    public CardDetailsViewModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }

    //购买会籍卡
    public BindingCommand goNext = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putString("card_id",String.valueOf(entity.get().getCard_id()));
            startActivity(BuyCardActivity.class,bundle);
        }
    });

    @Override
    protected void returnData(int code, Object dataBean) {
        super.returnData(code, dataBean);

        if(code == Constants.GET_CARD_INFO){

            CardDetailsBean bean = (CardDetailsBean)dataBean;
            entity.set(bean);
            
        }
    }
}
